const Router = require('koa-router');
const router = new Router();
const {db, QueryTypes} = require("../../models/db");
router.post('/scan/getIdByNo', async ctx => {
    let body = ctx.request.body
    let user = ctx.user
    let tenantId = user.tenantId;
    let billNo = body.billNo;
    let model = await db.models['invoice'].findOne({
        where: {
            tenantId,
            billNo
        }
    })
    if(model) {
        if(model.billType !== 'SALE') {
            return ctx.err('不是销售票据')
        }
        return ctx.suc('', model.transType+'-'+model.id)
    }
    return ctx.err('未找到票据')
})

module.exports = router;
